%% Copyright 2008 Kevin A. Smith 
%% Licensed under the Apache License, Version 2.0 (the "License"); 
%% you may not use this file except in compliance with the License. 
%% You may obtain a copy of the License at 
%%
%% http://www.apache.org/licenses/LICENSE-2.0 
%%
%% Unless required by applicable law or agreed to in writing, software 
%% distributed under the License is distributed on an "AS IS" BASIS, 
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
%% See the License for the specific language governing permissions and 
%% limitations under the License.

-module(startstop).

-compile(export_all).

run() ->
	Keys = aws_keys:new("YourIdentifier", "YourSecretKey"),
	case aws_instance:run(Keys, "gsg-keypair", "ami-0022c769") of
		{ok, [H|_T]} ->
			case aws_instance:terminate(Keys, proplists:get_value(instanceId, H)) of
				{ok, _Result} ->
					io:format("Instance terminated~n");
				{error, Error} ->
					io:format("Oops! Instance still running: ~p~n", [Error])
			end;
		{error, Error} ->
			io:format("Error: ~p~n", [Error]),	
			io:format("Oops! Running instance failed!~n")
	end.
	